import { request } from '@/utils/request'

//获取所有商品列表
export function getAllProducts (pageNum, pageSize) {
  return request({
    url: '/api/product/list?pageNum=' + pageNum + '&pageSize=' + pageSize,
    method: 'get'
  })
}

//删除某一商品
export function deleteProduct (productId) {
  return request({
    url: '/api/product/delete?productId=' + productId,
    method: 'delete'
  })
}

//模糊搜索商品
export function searchProduct (pageNum, pageSize, searchName, searchType) {
  return request({
    url: '/api/product/search',
    method: 'get',
    params: {
      pageNum: pageNum,
      pageSize: pageSize,
      [searchType]: searchName
    }
  })
}

//更新商品状态
export function updateProductStatus (params) {
  return request({
    url: '/api/product/updateStatus',
    method: 'put',
    data: params
  })
}

//添加商品
export function addProduct (params) {
  return request({
    url: '/api/product/add',
    method: 'post',
    data: params
  })
}

//更新商品
export function updateProduct (params) {
  return request({
    url: '/api/product/update',
    method: 'put',
    data: params
  })
}

//删除图片
export function deleteImg (name) {
  return request({
    url: '/api/img/delete',
    method: 'delete',
    data: name
  })
}